package lib

import (
	"github.com/kataras/iris"
	"github.com/kataras/iris/sessions"
	"github.com/spf13/viper"
)

var (
	cookieNameForSessionID = "mycookiesessionnameid"
	Session_               = sessions.New(sessions.Config{Cookie: cookieNameForSessionID})
)

// session对象操作
func SessionObj(ctx iris.Context) *sessions.Session {
	return Session_.Start(ctx)
}

// @title 初始化自定义参数
func InitCustomParam() {
	customParam := map[string]interface{}{
		"limit": 10,
	}
	viper.Set("coreParam", customParam)
}

// @title 获取自定义参数
func GetCustomParam(name string) interface{} {
	customParam := viper.Get("coreParam").(map[string]interface{})
	return customParam[name]
}
